package com.jisf.driver.controller;

import com.jisf.driver.entity.po.Examine;
import com.jisf.driver.entity.vo.ExamineListRequestVo;
import com.jisf.driver.entity.vo.ExamineListResponseVo;
import com.jisf.driver.entity.vo.ExamineVo;
import com.jisf.driver.entity.vo.StudentExamineResponseVo;
import com.jisf.driver.response.Result;
import com.jisf.driver.response.ResultCode;
import com.jisf.driver.service.IExamineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jisf
 * @since 2022-05-10
 */
@RestController
@RequestMapping("/driver/examine")
public class ExamineController {

    @Autowired
    private IExamineService iExamineService;

    @PostMapping("list")
    @PreAuthorize("hasAnyAuthority('examine:list')")
    public Result<?> getExamineList(@RequestBody ExamineListRequestVo examineListRequestVo){
        ExamineListResponseVo examineList = iExamineService.getExamineList(examineListRequestVo);
        return Result.ok(examineList);
    }

    @GetMapping("appointList")
    @PreAuthorize("hasAnyAuthority('examine:appointList')")
    public Result<?> getExamineAppointList(){
        List<StudentExamineResponseVo> examineAppointList = iExamineService.getExamineAppointList();
        return Result.ok(examineAppointList);
    }

    @GetMapping("allotList")
    @PreAuthorize("hasAnyAuthority('examine:allotList')")
    public Result<?> getExamineAllotList(){
        List<Examine> examineAppointList = iExamineService.getExamineAllotList();
        return Result.ok(examineAppointList);
    }

    @PostMapping("add")
    @PreAuthorize("hasAnyAuthority('examine:add')")
    public Result<?> addExamine(@RequestBody ExamineVo examineVo){
        ResultCode resultCode = iExamineService.addExamine(examineVo);
        return Result.ok(resultCode);
    }
    
    @GetMapping("finish/appoint")
    @PreAuthorize("hasAnyAuthority('examine:finish:appoint')")
    public Result<?> finishAppoint(@RequestParam Integer id){
        ResultCode resultCode = iExamineService.finishAppoint(id);
        return Result.ok(resultCode);
    }



}
